<?php

class Post extends API_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->model('post_model');
    }

    public function wall() {
        $params = $this->params;
        if (empty($params['fb_id']) == TRUE) {
            $this->response('INVALID_PARAMS');
        }
        
        $args['fb_id'] = intval($params['fb_id']);
        $args['type'] = 1;

        $result = $this->post_model->get($args);
        if (empty($result) == FALSE) {
            $this->response('GET_SUCCESS', $result);
        } else {
            $this->response('GET_FAIL', $result);
        }
    }

    public function friend() {
        $params = $this->params;
        if (empty($params['fb_id']) == TRUE) {
            $this->response('INVALID_PARAMS');
        }
        
        $args['fb_id'] = intval($params['fb_id']);
        $args['type'] = 2;

        $result = $this->post_model->get($args);
        if (empty($result) == FALSE) {
            $this->response('GET_SUCCESS', $result);
        } else {
            $this->response('GET_FAIL', $result);
        }
    }

    public function group() {
        $params = $this->params;
        if (empty($params['fb_id']) == TRUE) {
            $this->response('INVALID_PARAMS');
        }
        
        $args['fb_id'] = intval($params['fb_id']);
        $args['type'] = 3;

        $result = $this->post_model->get($args);
        if (empty($result) == FALSE) {
            $this->response('GET_SUCCESS', $result);
        } else {
            $this->response('GET_FAIL', $result);
        }
    }

    public function index() {
        $params = $this->params;
        if (empty($params['fb_id']) == TRUE) {
            $this->response('INVALID_PARAMS');
        }

        $args['fb_id'] = intval($params['fb_id']);

        $result = $this->post_model->get($args);
        if (empty($result) == FALSE) {
            $this->response('GET_SUCCESS', $result);
        } else {
            $this->response('GET_FAIL', $result);
        }
    }

}
